package main;
import java.io.IOException;
import java.io.InputStream;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;

import beans.helloWorld;

public class test {

	public static void main(String[] args) throws IOException {
	
			ApplicationContext context = new FileSystemXmlApplicationContext("src/main/resources/applicationContext.xml");
			
			helloWorld hel = (helloWorld) context.getBean("helloWorld");
			hel.print();
			
			
			/* mybatis ����*/
			//����sql����
			String  resources = "mybatis-config.xml"; //�����ļ���ַ
			
			InputStream is = Resources.getResourceAsStream(resources);
			
			SqlSessionFactory fac = new  SqlSessionFactoryBuilder().build(is);
			
			SqlSession sqls = fac.openSession();
			
			String name = sqls.selectOne("entity.myuser.getName", 1);
			
			System.out.println(name);
			
			sqls.close();
			
					
	}

}
